﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using JWUX.Supermarket.IDAL;

namespace JWUX.Supermarket.Components
{
    public sealed class DataAccess
    {
        private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["DALType"];

        /// <summary>
        /// 实例化UserDAL
        /// </summary>
        /// <returns></returns>
        public static IUser CreateUser()
        {
            string className = path + ".User";
            return (IUser)Assembly.Load(path).CreateInstance(className);
        }

        /// <summary>
        /// 实例化RequestDAL
        /// </summary>
        /// <returns></returns>
        public static IRequest CreateRequest()
        {
            string className = path + ".Request";
            return (IRequest)Assembly.Load(path).CreateInstance(className);
        }

        public static IBOM CreateBOM()
        {
            string className = path + ".BOM";
            return (IBOM)Assembly.Load(path).CreateInstance(className);
        }

        public static ILocation CreateLocation()
        {
            string className = path + ".Location";
            return (ILocation)Assembly.Load(path).CreateInstance(className);
        }
    }
}
